package com.estar.assistsurvy.activity;

import com.estar.assistsurvy.R;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import cn.jpush.android.api.JPushInterface;

public class DialogActivity extends BaseActivity implements OnClickListener{

	private TextView contentBox;
	private Button confirmBt,cancelBt;
	private Intent intent;
	private SharedPreferences userPrefer,rolePrefer;
	private Activity activity;
	private String message;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_dialog);
		init();
	}
	
	private void init(){
		activity=DialogActivity.this;
		intent=getIntent();
		message=intent.getStringExtra("message");
		contentBox=find(R.id.contentBox);
		contentBox.setText(message);
		confirmBt=find(R.id.confirmBt);
		confirmBt.setText("退出");
		confirmBt.setOnClickListener(this);
		cancelBt=find(R.id.cancelBt);
		cancelBt.setText("重新登录");
		cancelBt.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch (v.getId()) {
		case R.id.confirmBt:
			userPrefer.edit().clear().commit();
			rolePrefer.edit().clear().commit();
			JPushInterface.setAliasAndTags(getApplicationContext(), "", null,null);
			intent=new Intent(activity, LoginActivity.class);
			startActivity(intent);
			finish();
			break;
			
		case R.id.cancelBt:
			userPrefer.edit().clear().commit();
			rolePrefer.edit().clear().commit();
			JPushInterface.setAliasAndTags(getApplicationContext(), "", null,null);
			intent=new Intent(activity, LoginActivity.class);
			startActivity(intent);
			finish();
			break;

		default:
			break;
		}
	}
}
